<!--
* description: 采购管理-欠拨单查询
* author: hzm
* createdDate: 2021-1-22
-->
<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamic-buttons="tableButtons"
      :dynamic-components="tableComponents"
      :dynamic-api-config="dynamicApiConfigs"
      :dynamic-table-cols="tableCols"
      :dynamic-form-fields="formField"
      :dynamic-is-show-select="false"
      :dynamic-is-init-table="true"
      :dynamic-is-fix-choose="false"
      :dynamic-is-fix-index="false"
      :dynamic-is-show-more-btn="true"
      :dynamic-api-style="'restful'"
    />
  </div>
</template>

<script>
import { oneTableWithViewTemplateMixins } from '@/components/mixins/oneTableWithViewTemplateMixins'
import OneTableTemplate from '@/components/templates/oneTable'
import { orgApis } from '@/api/paSparePartsManagement'
import { exportExcel } from '@/utils/getTimeString.js'

export default {
  name: 'QuiryBackCall',
  components: {
    OneTableTemplate
  },
  mixins: [oneTableWithViewTemplateMixins],
  data() {
    return {
      dynamicApiConfigs: orgApis.queryUnderdialOrderInfo,
      // 动态生成网格列
      tableCols:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          .length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          : [
            {
              prop: 'dlrCode',
              label: '网点编码',
              align: 'center'
            },
            {
              prop: 'dlrShortName',
              label: '网点名称',
              align: 'center'
            },
            {
              prop: 'partNo',
              label: '备件编码',
              align: 'center'
            },
            {
              prop: 'partName',
              label: '备件名称',
              align: 'center'
            },
            {
              prop: 'purOrderTypeCn',
              label: '订单类型',
              align: 'center'
            },
            {
              prop: 'purOrderCode',
              label: '订单编号',
              align: 'center'
            },
            {
              prop: 'purQty',
              label: '订单数量',
              align: 'center'
            },
            {
              prop: 'underdialQty',
              label: '欠拨数量',
              align: 'center'
            },
            {
              prop: 'underdiaDate',
              label: '欠拨产生日期',
              align: 'center'
            },
            {
              prop: 'underdialTime',
              label: '欠拨时长',
              align: 'center'
            },
            {
              prop: 'underdiaStatusCn',
              label: '欠拨状态',
              align: 'center'
            },
            {
              prop: 'remark',
              label: '备注',
              align: 'center'
            }
          ],
      tableComponents:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents.length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
            .tableComponents
          : [
            // 库存状态
            {
              compKey: 'compKey1',
              labelName: '网点编码：',
              codeField: 'dlrShortName',
              textField: 'dlrCode',
              component: () => import('@/views/ve/planReport/components/multipleSearchInput'),
              isMust: true,
              dataToObject: {
                oFields: 'dlrShortName,dlrCode',
                // 控制弹窗页面 搜索 网格 元素
                tableComponents: [
                  {
                    compKey: 'compKey1',
                    labelName: '网点编码：',
                    codeField: 'dlrCode',
                    component: () => import('@/components/org/commonInput'),
                    type: 'inputText',
                    isMust: true,
                    span: 8
                  },
                  {
                    compKey: 'compKey2',
                    labelName: '网点名称：',
                    codeField: 'dlrShortName',
                    component: () => import('@/components/org/commonInput'),
                    type: 'inputText',
                    isMust: true,
                    span: 8
                  }
                ],
                tableCols: [
                  {
                    prop: 'dlrCode',
                    label: '网点编码'
                  },
                  {
                    prop: 'dlrShortName',
                    label: '网点名称'
                  }
                ],
                formField: {
                  dlrShortName: '',
                  dlrCode: ''
                },
                returnField: {
                  prop: 'dlrCode',
                  label: '网点编码'
                },
                api: orgApis.queryOrgDlrCodes
              },
              span: 6
            },
            // 车辆状态
            {
              compKey: 'compKey4',
              labelName: '网点名称：',
              codeField: 'dlrShortName',
              disabled: true,
              component: () => import('@/components/org/commonInput'),
              isMust: true,
              span: 6
            },
            // 入库仓库
            {
              compKey: 'compKey5',
              labelName: '订单编码：',
              codeField: 'purOrderCode',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              isMust: true,
              span: 6
            },
            // 审核状态
            {
              compKey: 'compKey6',
              labelName: '订单类型：',
              codeField: 'purOrderType',
              textField: 'partRepairTypeName',
              customObj: {
                api: orgApis.queryDropDownList
              },
              component: () => import('@/components/org/commonSelect'),
              type: 'dropdownList',
              isMust: true,
              span: 6
            },
            {
              compKey: 'compKey7',
              labelName: '欠拨日期：',
              codeField: 'beginDate,endDate',
              component: () => import('@/components/org/datePicker/andtDatePicker'),
              type: 'YYYY-MM-DD',
              format: 'yyyy-MM-dd',
              dateOptionsType: '0',
              isMul: false,
              isMust: false,
              span: 6
            },
            {
              compKey: 'compKey8',
              labelName: '备件编码：',
              codeField: 'partNo',
              lookuptype: 'VE0212',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              isMust: false,
              span: 6
            },
            {
              compKey: 'compKey9',
              labelName: '备件名称：',
              codeField: 'partName',
              lookuptype: 'VE0212',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              isMust: false,
              span: 6
            },
            {
              compKey: 'compKey10',
              labelName: '欠拨状态：',
              codeField: 'underdiaStatus',
              lookuptype: 'VE0212',
              component: () => import('@/components/org/LookupValue'),
              oFields: 'statusId,statusText',
              options: [
                { statusId: '1', statusText: '结案' },
                { statusId: '0', statusText: '欠拨' }
              ],
              type: 'dropdownList',
              isMul: false,
              isMust: false
            }
          ],
      tableButtons: [
        {
          conmpKey: 'btenKey1',
          type: 'primary',
          size: 'small',
          text: '查询',
          name: 'search',
          clickEvent: () => this.queryTable(1),
          position: 'right'
        },
        {
          conmpKey: 'btenKey3',
          type: '',
          size: 'small',
          clickEvent: () => this.export(),
          text: this.$t('sys.button.export'),
          name: 'export',
          position: 'right' // 导出
        },
        {
          conmpKey: 'btenKey2',
          type: '',
          size: 'small',
          text: '重置',
          name: 'reset',
          clickEvent: () => this.reset(),
          position: 'right'
        }
      ],
      formField: this.$utils.getFormField(this, {
        beginDate: '',
        endDate: '',
        dlrCode: '',
        dlrShortName: '',
        purOrderCode: '',
        purOrderType: '',
        underdiaDate: '',
        partNo: '',
        partName: '',
        underdiaStatus: ''
      })
    }
  },
  mounted() {
    this.queryTable(1)
    // this.$refs.multipleTable.list = [
    //   {
    //     index: 1,
    //   },
    // ];
  },
  methods: {
    export() {
      exportExcel(this.formField, orgApis.exportDetails.APIUrl, orgApis.exportDetails.ServiceCode, '欠拨单查询')
    }
  }
}
</script>

<style>
</style>
